import {Component, OnInit} from '@angular/core';
import {Article} from "../entity/article";
import {ArticleService} from "../service/article.service";

@Component({
  moduleId: module.id,
  selector: 'my-article-list',
  templateUrl: 'article-list.component.html',
  styleUrls: ['article-list.component.css'],
  providers: [ArticleService]
})

export class ArticleListComponent implements OnInit{

  constructor(private articleService: ArticleService) {}

  articles: Article[];
  page = 1;

  ngOnInit() {
    this.articleService.getArticles(this.page).subscribe((articles) => this.articles = articles);
  }

  pageChange($event:any) {
    this.articleService.getArticles($event).subscribe((articles) => this.articles = articles);
  }
}
